package com.jt.provider.controller;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 通过controller中的方法演示日志级别应用以及配置中心的作用
 */
@Slf4j
@RestController
@RefreshScope //假如希望配置中心内容发生变化,要对类中属性进行重新初始化,可使用此注解对类描述
public class ProviderLogController {


    @GetMapping("/provider/log/doLog01")
    public String doLog01(){
        //日志级别  trace < debug < info < warn < error
        log.trace("===trace===");
        log.debug("===debug===");
        log.info("===info===");//springboot工程默认日志级别为info
        log.warn("===warn===");
        log.error("===error===");
        return "test log level";
    }


    @Value("${logging.level.com.jt:error}")
    private String logLevel;

    @GetMapping("/provider/log/doLog02")
    public String doLog02(){
        log.info("log level is  {}",logLevel);
        return  "log level  is "+logLevel;
    }












}
